const fn1 = () => {
    return new Promise((resolve, reject) => {
        setTimeout(() => {
            resolve(1);
        }, 300);
    });
}
const fn2 = () => {
    return new Promise((resolve, reject) => {
        setTimeout(() => {
            resolve(2);
        }, 600);
    });
}
// 改进fn
// const fn = () => {
//     fn1().then(res1 => {
//         console.log(res1);
//         fn2().then(res2 => {
//             console.log(res2);
//         });
//     });
// }
async function fnn() {
    const a1= await fn1()
    console.log(a1);
    const a2= await fn2()
    console.log(a2);
}

fnn()

// 用promise.all也可以
// const fn = () => {
//     return Promise.all([fn1(), fn2()])
//        .then(([res1, res2]) => {
//             console.log(res1);
//             console.log(res2);
//         });
// };